package com.gogowan.agroenterprise.widget.adapter;

import java.util.List;

import com.gogowan.agroenterprise.R;
import com.gogowan.agroenterprise.model.CollectData;
import com.gogowan.agroenterprise.model.CollectHistory;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
/**
 * 标签采集缓存Adapter
 * @author app
 *
 */
public class CollectHistoryAdapter extends BaseAdapter {

	private List<CollectHistory> datas;

	private Context context;

	public CollectHistoryAdapter(List<CollectHistory> datas, Context context) {
		this.datas = datas;
		this.context = context;
	}

	@Override
	public int getCount() {
		return datas.size();
	}

	@Override
	public Object getItem(int position) {
		return datas.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder;
		if (convertView == null) {
			viewHolder = new ViewHolder();
			convertView = LayoutInflater.from(context).inflate(R.layout.layout_collect_history_item, null);
			viewHolder.xh = (TextView) convertView.findViewById(R.id.xh);
			viewHolder.jdsj = (TextView) convertView.findViewById(R.id.jdsj);
			viewHolder.jdr = (TextView) convertView.findViewById(R.id.jdr);
			viewHolder.bqsl = (TextView) convertView.findViewById(R.id.bqsl);
			convertView.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}
		viewHolder.xh.setText(position + 1 + "");
		viewHolder.jdsj.setText(datas.get(position).getOrderTime());
		viewHolder.jdr.setText(datas.get(position).getOperMan());
		viewHolder.bqsl.setText(datas.get(position).getTagNum());
		return convertView;
	}

	static class ViewHolder {
		TextView xh;
		TextView jdsj;
		TextView jdr;
		TextView bqsl;
	}
}
